package com.qdu.mapper;

import com.qdu.bean.bikeWritable;
import com.qdu.bean.year_seasonBean;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class rentByYear_SeasonMapper    extends Mapper<LongWritable, Text, year_seasonBean, bikeWritable> {
    year_seasonBean ys=new year_seasonBean();
    bikeWritable    bw4=new bikeWritable();

    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {

        String  line=value.toString();
        String[]    data=line.split(",");
        String[]    time=data[0].split("/");


            int casual = Integer.parseInt(data[9]);
            int registered = Integer.parseInt(data[10]);
            int count = Integer.parseInt(data[11]);
            bw4.set2(casual,registered,count);


        String  year=time[0];
        int  season=Integer.parseInt(data[1]);
        ys.set(year,season);

        context.write(ys,bw4);
    }


}
